//Customer.h
#ifndef Customer_H
#define Customer_H

#include "list.h"
#include "synch.h"
#include <stdarg.h>

class Cineplex;
class Ticket;
class Line;
class Popcorn;
class Soda;

class Customer
{
	public:
		Customer(char* name, int group, IterList* underlings);
		~Customer();
		void SendMessage(char* name, int argc, ...);
		void SendMessage(char* name, IterList* args);
		void Scheduler();
		void Start();
		
		//LEADER ACTIONS
		void JoinTixLine();
		void WaitTixLine();
		void CheckNewTixLine();
		void RecTixClerk();
		void TixOrderPlaced();
		void TixPaySent();
		void AskSubsFood();
		void WaitSubFood();
		void JoinFoodLine();
		void WaitFoodLine();
		void CheckNewFoodLine();
		void RecFoodClerk();
		void PopcornOrderPlaced();
		void DrinkOrderPlaced();
		void FoodPaySent();
		void JoinEntryLine();
		void WaitEntryLine();
		void CheckNewEntryLine();
		void RecTixTaker();
		void GaveTix();
		void TellSubsGoIn();
		void LeadGoIn();
		//void SendSubsSeats();
		//void LetSubsSit();
		void WatchingMovie();
		void LeadRegroup();
		void AskUseBR();
		void FindOutBR();
		void WaitBR();
		void LeaveCineplex();
		void GoToLobby();
		void InLobby();
		void RecSizeRequest();
		
		//SUB ACTIONS
		void sNewSub();
		void sSendFoodOrder();
		void sFoodOrderSent();
		void sRecGoIn();
		void sWaitForSeat();
		//void sRecievedSeat();
		void sWatchingMovie();
		void sRegroup();
		void sLeaveTheater();
		void sAskedBR();
		void sUseBR();
		void sWaitBR();
		void sLeaveCineplex();
		
		//test patterns
		void CT1();
		void CT3();
		void CT4();
		
		MsgList* msgList;
		void* replyTo;
		Lock* msgLock;
		char* myName;
		Condition* sleepCon;
		int repliesWaiting, msgsToSend;
		char* state;
		
		int numSubs, numPopcorn, numSoda;
		int myRow, myCol;
		int groupNumber;
		IterList* subs;
		IterList* brQueue;
		Ticket* tickets;
		Popcorn* popcorns;
		Soda* sodas;
		float money;
		Cineplex* cinema;
		Line* currentLine;
		
		//get around stupid compiler inlining issues
		int msgInt;
		float msgFloat;
};


#endif
